package net.gdface.sdk.fse;

import net.gdface.utils.FaceUtilits;

/**
 * @author guyadong
 *
 */
public class FeatureSeDecorator implements FeatureSe {
	private final FeatureSe delegate;
	
	public FeatureSeDecorator(FeatureSe delegate) {
		if(null == delegate){
			throw new NullPointerException("delegate is null");
		}
		this.delegate = delegate;
	}

	public static FeatureSeDecorator makeDecorator(FeatureSe featurese){
		if(featurese instanceof FeatureSeDecorator){
			return (FeatureSeDecorator)featurese;
		}
		return new FeatureSeDecorator(featurese);
	}
	public FeatureSe delegate(){
		return delegate;
	}
	@Override
	public CodeBean[] searchCode(byte[] code, double sim, int rows) {
		return delegate.searchCode(code, sim, rows);
	}

	@Override
	public CodeBean getFeature(byte[] featureId) {
		return delegate.getFeature(featureId);
	}

	@Override
	public boolean addFeature(byte[] featureId, byte[] feature, String imgMD5) {
		return delegate.addFeature(featureId, feature, imgMD5);
	}
	
	@Override
	public boolean addFeature(byte[] featureId, byte[] feature, long appid) {
		return delegate.addFeature(featureId, feature, appid);
	}

	@Override
	public boolean removeFeature(byte[] featureId) {
		return delegate.removeFeature(featureId);
	}

	@Override
	public int size() {
		return delegate.size();
	}

	/**
	 * @param featureId
	 * @return
	 * @see FeatureSe#getFeature(byte[])
	 */
	public CodeBean getFeature(String featureId) {
		return delegate.getFeature(FaceUtilits.hex2Bytes(featureId));
	}

	/**
	 * @param featureId
	 * @param feature
	 * @param imgMD5 
	 * @return
	 * @see FeatureSe#addFeature(byte[], byte[], String)
	 */
	public boolean addFeature(String featureId, byte[] feature, String imgMD5) {
		return delegate.addFeature(FaceUtilits.hex2Bytes(featureId), feature, imgMD5);
	}

	/**
	 * @param featureId
	 * @return
	 * @see FeatureSe#removeFeature(byte[])
	 */
	public boolean removeFeature(String featureId) {
		return delegate.removeFeature(FaceUtilits.hex2Bytes(featureId));
	}
}
